package com.test.pusher;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.LoginFilter;
import android.view.SurfaceView;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private CameraHelper mCameraHelper;
    private Pusher mPusher;

//    static {
//        System.loadLibrary("native-lib");
//    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        TextView tv = findViewById(R.id.sample_text);
//        tv.setText(stringFromJNI());
        // 权限判断
        if(PermissionUtil.isNeedRequestPermission(this)){
            mPusher = new Pusher(this);
            SurfaceView surfaceView = findViewById(R.id.surfaceView);
            mPusher.setPreviewDisplay(surfaceView.getHolder());
        }

    }

    /**
     * 转换摄像头
     * @param view
     */
    public void switchCamera(View view){
        if(mPusher != null){
            mPusher.switchCamera();
        }
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();

    public void startLive(View view) {
        mPusher.startLive("rtmp://121.41.33.93/myapp/");
    }

    public void stopLive(View view) {
        mPusher.stopLive();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPusher.release();
    }
}
